<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Storage;

class Agent extends Model
{
    use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'agent';
    //查询时隐藏字段
    protected $hidden = ['created_at', 'updated_at', 'deleted_at'];

    protected $guarded = [];


    public function getImage()
    {
        if (Str::contains($this->image, '//')) {
            return $this->image;
        }

        return Storage::disk('admin')->url($this->image);
    }
}
